<?php
/**
 * Description of frofile
 * 
 * @author anhdung
 * @since 02-07-2013 - 09:28:50
 */
?>
<div class="row-fluid">
    <div class="box span12">
        <div class="box-header">
            <h2><i class="icon-user"></i><span class="break"></span>Profile</h2>            
        </div>
        <div class="box-content">
            <?php if (Yii::app()->user->hasFlash('Success_profile')): ?>
                <div class="alert alert-success">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                    <strong>All done!</strong> <?php echo Yii::app()->user->getFlash('Success_profile'); ?>
                </div>
            <?php endif; ?>
            <?php if (Yii::app()->user->hasFlash('Error_profile')): ?>
                <div class="alert alert-error">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                    <strong>Oh snap!</strong> <?php echo Yii::app()->user->getFlash('Error_profile'); ?>
                </div>
            <?php endif; ?>
            <?php
            $form = $this->beginWidget('CActiveForm', array(
                'id'                     => 'profile-form',
//                'enableAjaxValidation' => true,
                'enableClientValidation' => true,
                'htmlOptions'            => array(
                    'class'   => 'form-horizontal',
                    'enctype' => 'multipart/form-data',
                ),
            ));
            ?>
            <fieldset>
                <div class="row-fluid">
                    <div class="span6">
                        <div class="control-group">
                            <?php echo $form->labelEx($model, 'photo', array('class' => 'control-label')); ?>
                            <div class ="controls">
                                <div class="user_photo">
                                    <img src="<?php echo $model->publicPhoto ?>" alt="User photo">
                                </div>                                
                                <input type="file" name="file"/>
                            </div>
                        </div>                        
                        <div class="control-group">
                            <?php echo $form->label($model, 'password', array('class' => 'control-label')) ?>
                            <div class ="controls">
                                <a class="btn btn-info" href="<?php echo $model->changePassUrl ?>">
                                    Change Password
                                </a>
                            </div>
                        </div>
                        <div class="control-group">
                            <?php echo $form->label($model, 'email', array('class' => 'control-label')) ?>
                            <div class ="controls">                                
                                <p><?php echo $model->email ?></p>
                                <a class="btn btn-info" href="<?php echo $model->changeEmailUrl ?>">
                                    Change Email
                                </a>
                            </div>
                        </div>
                    </div>
                    <?php
                    if ($model->type == Users::TYPE_BUSINESS)
                    {
                        echo $this->renderPartial('//user/_form_biz', array(
                            'form'      => $form,
                            'model'     => $model,
                            'isProfile' => TRUE,
                        ));
                    }
                    else
                    {
                        echo $this->renderPartial('//user/_form_basic', array(
                            'form'      => $form,
                            'model'     => $model,
                            'isProfile' => TRUE,
                        ));
                    }
                    ?>
                    <div class="clearfix"></div>
                    <div class="form-actions">
                        <?php echo CHtml::submitButton('Save', array('class' => 'btn btn-primary')); ?>
                        <?php echo CHtml::resetButton('Reset', array('class' => 'btn')); ?>
                    </div>
                </div>
            </fieldset>
            <?php $this->endWidget(); ?>
        </div>
    </div>
</div>
